Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the context enrich function doesn't overwrite existing variables #29

Merged
merged 2 commits into from
Mar 25, 2017

Conversation

djbe
Copy link
Member

@djbe djbe commented Mar 5, 2017

context[StencilContext.environment] = environment
context[StencilContext.parameters] = try Parameters.parse(items: parameters)
context[self.environment] = merge(context[self.environment], with: environment)
context[self.parameters] = merge(context[self.parameters], with: try Parameters.parse(items: parameters))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should rename those two static let constants using environmentKey and parametersKey.

Because the first time i read and reviewed your code change I didn't understand why you used instance properties there, and almost thought that self.environment were referring to the [String: String] dictionary of the context, containing the env variables (ok, doing the review from GitHub didn't help, as the limited git diff scope failed to remind me that this was actually inside a static func…). Using context[self.paramtersKey] should help clarify that.

Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except from the renaming idea, LGTM

@djbe djbe merged commit 71c7a25 into master Mar 25, 2017
@djbe djbe deleted the feature/merge-context branch March 25, 2017 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants